<?php
/**
 * Source for import Store to get store view default
 *
 * @category   Magestore
 * @package    Magestore_Mageconnector
 * @author     Nguyen Minh Dung (http://magestore.com)
 */
class Magestore_Mageconnector_Model_Importstore
{
    public function toOptionArray()
    {
  		$collection = Mage::getResourceModel('core/website_collection');
  		
  		$options = array();
  		
		foreach($collection as $website) {
			
			$goupcollection = $website->getGroupCollection();
  			foreach($goupcollection as $group) {
  				
  				$storecollection = $group->getStoreCollection();
  				foreach ($storecollection as $store) {
  					
  					if ($website->__get('is_default') &&
					  		$website->__get('default_group_id') == $group->getId() &&
							$group->__get('default_store_id') == $store->getId()) {
			  			$options[] = array(
							'value'	=> $store->code,
							'label'	=> $website->getName().' / '.$group->getName().' / '.$store->getName()
						);
						break;
  					}
  				}
			}
  		}
  		
  		foreach($collection as $website) {
			
			$goupcollection = $website->getGroupCollection();
  			foreach($goupcollection as $group) {
  				
  				$storecollection = $group->getStoreCollection();
  				foreach ($storecollection as $store) {
  					
  					if ($website->__get('is_default') &&
					  		$website->__get('default_group_id') == $group->getId() &&
							$group->__get('default_store_id') == $store->getId()) {
			  			continue;
  					} else {
  						$options[] = array(
							'value'	=> $store->code,
							'label'	=> $website->getName().' / '.$group->getName().' / '.$store->getName()
						);
  					}
  				}
			}
  		}
  		
        return $options;
    }
}
